package cn.tedu.analyse.service.impl;

import cn.tedu.analyse.dao.mapper.LikesMapper;
import cn.tedu.analyse.pojo.entity.Likes;
import cn.tedu.analyse.service.LikesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Slf4j
@Service
public class LikesServiceImpl implements LikesService {

    @Autowired
    private LikesMapper likesMapper;

    @Override
    public void createLikes(Long commentId , Long userId) {
        log.debug("创建点赞，commentId：{},userId:{}",commentId,userId);
        Likes likes = new Likes();
        likes.setContentId(commentId);
        likes.setUserId(userId);
        likes.setCreatedAt(new Date());
        likesMapper.createLikes(likes);
        log.debug("点赞创建成功,commentId：{},userId:{}",commentId,userId);
    }

    @Override
    public void deleteLikes(Long commentId , Long userId) {
        log.debug("删除点赞，commentId：{},userId:{}",commentId,userId);
        Likes likes = new Likes();
        likes.setContentId(commentId);
        likes.setUserId(userId);
        likesMapper.deleteLikes(likes);
        log.debug("点赞删除成功,commentId：{},userId:{}",commentId,userId);
    }
}
